import java.util.Scanner;

public class HomeWork {
    public String name = "admin";
    public String password = "123456";
    public void login(String name,String password) throws UserNameException,UserCodeException{
        if (!this.name.equals(name)){
            System.out.println("用户名错误");
            throw new UserNameException();
        }
        if (!this.password.equals(password)){
            System.out.println("密码错误");
            throw new UserCodeException("密码不符！！！");
        }
    }

    public static void main(String[] args) {
        HomeWork homeWork = new HomeWork();
        try(Scanner scanner = new Scanner(System.in)){
            System.out.println("请输入用户名：");
            String a = scanner.nextLine();
            System.out.println("请输入密码：");
            String b = scanner.nextLine();
            homeWork.login(a,b);
        }catch (UserCodeException userCodeException){
            userCodeException.printStackTrace();
            System.out.println("密码错误2.0");
        }catch (UserNameException userNameException){
            userNameException.printStackTrace();
            System.out.println("用户名错误2.0");
        }finally {
            System.out.println("请重新输入");
        }
    }
}
